from django_filters.rest_framework import FilterSet
from django_filters.filters import *
from .models import *


class NodeFilterSet(FilterSet):
    name = CharFilter(lookup_expr="contains")
    address = CharFilter(lookup_expr="contains")
    start_time = DateFilter(
        field_name="create_time", lookup_expr="gte", label="开始日期"
    )
    end_time = DateFilter(field_name="create_time", lookup_expr="lt", label="结束日期")

    class Meta:
        model = Node
        fields = ["name", "address", "status", "start_time", "end_time"]
